package com.zang.array;

/**
 * @Author: ZVerify
 * @Description: TODO
 * @DateTime: 2022/9/30 14:39
 **/
public class 二维数组中的查找 {

    public boolean findNumberIn2DArray(int[][] matrix,
                                       int target) {

        if (matrix.length == 0){
            return Boolean.FALSE;
        }
        int i = 0;
        int j = matrix[0].length-1;
        while (i<matrix.length && j>=0){
            if (matrix[i][j] < target){
                i++;
            }else if (matrix[i][j] > target){
                j--;
            }else {
                return Boolean.TRUE;
            }
        }

        return Boolean.FALSE;
    }
}
